<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>块级作用域</title>
</head>

<body>
    <script>
        {
            var b = 1;//ES5声明一个变量
            let a = 10;//ES6声明一个局部变量   
        }
        // console.log(a)
        console.log(b)
        var shi = 0, bai = 0;
        for (var i = 1; i <= 10; i++) {
            shi = shi + i;
        }
        console.log(shi)
        for (let i = 1; i <= 100; i++) {
            bai = bai + i;
        }
        console.log(bai)
        console.log("******************************")
        console.log(c)
        var c = 2;
        let d = 2
        console.log(d)
        function fn1(){
            // var a = 10;
            // var a = 1;
            let a = 10;
            // let a = 1;
            console.log(a)
        }
        fn1();
    </script>
</body>

</html>